{% extends "base.volt" %}

{% block pageFooter%}
    <script type="text/javascript">
        var domainPic = '{{ this.di.get('appConfig').application.domainPic }}';
        var picUploadUrl = '{{ url.get('tools/editorPTUploadImg', ['callback':'parent.setFormResultImg', 'type':'banner']) }}';
    </script>
    {{ javascript_include("/assets/manage/js/om/bannerIndex.js", false) }}
{% endblock %}

{% block content %}
    {{ partial("module/left_om") }}
    <div class="col-xs-10">
        <ol class="breadcrumb">
            <li>运营</li>
            <li>Banner位管理</li>
            <li class="active">首页轮播</li>
        </ol>

        <div class="panel panel-default">
            <div class="panel-body">
                <form class="form-inline" role="form" action="" method="get">
                    <div class="form-group">
                        <div class="input-group">
                            <label class="input-group-addon">城市</label>
                            <select class="form-control" name="filterCity" id="filterCity">
                                {% if filterCity == 0 %}
                                    <option value="0" {{ filterCity == 0 ? 'selected="selected"' : '' }} >请选择</option>
                                {% endif %}
                                {% for oc in openCity %}
                                    <option value="{{ oc.city_id }}" {{ filterCity == oc.city_id ? 'selected="selected"' : '' }} >{{ oc.city_name|e }}</option>
                                {% endfor %}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary"><i class="fa fa-filter"></i> 查 询</button>
                    </div>
                </form>
            </div>
        </div>

        {% if filterCity > 0 %}

        <div id="data_box">
            {% if count(data) > 0 %}
            {% for d in data %}
            <div class="panel panel-default banner_item">
            <!--
                <button class="btn btn-danger btn-sm banner_item_del" onclick="deleteItem(this)"><i class="fa fa-trash-o fa-lg"></i> 删除</button>
                -->
                <div class="panel-body form-horizontal">
                    <div class="form-group">
                        <label for="service_cover" class="col-xs-2 control-label">图片</label>
                        <div class="col-xs-9">
                            <img src="{{ this.di.get('appConfig').application.domainPic }}{{ d['url'] }}" durl="{{ d['url'] }}" class="item_url" />
                            <button type="button" class="btn btn-warning btn-xs but_update_pic" onclick="uploadPic(this)"><i class="fa fa-pencil"></i>上传图片</button>
                            <p class="help-block">支持jpg、png图片格式，尺寸必须是750x330px，大小不得超过1M。</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="service_cover" class="col-xs-2 control-label">点击处理类型</label>
                        <div class="col-xs-3">
                            <select class="form-control item_link_type">
                                <option value="">请选择...</option>
                                <option value="none" {{ d['link_type'] == 'none' ? 'selected="selected"' : '' }}>点击无跳转</option>
                                <option value="question" {{ d['link_type'] == 'question' ? 'selected="selected"' : '' }}>问题详情</option>
                                <option value="activity" {{ d['link_type'] == 'activity' ? 'selected="selected"' : '' }}>活动详情</option>
                                <option value="url" {{ d['link_type'] == 'url' ? 'selected="selected"' : '' }}>内部打开网页</option>
                                <option value="beautyParlor" {{ d['link_type'] == 'beautyParlor' ? 'selected="selected"' : '' }}>美容院详情</option>
                                <option value="beautyParlorService" {{ d['link_type'] == 'beautyParlorService' ? 'selected="selected"' : '' }}>美容院服务详情</option>
                            </select>
                        </div>
                    </div>
                    <!--新增banner排序功能-->
                    <div class="form-group">
                		<label  for="service_cover" class="col-xs-2 control-label">排序ID</label>
                		<div class="col-xs-3">
                    		<select class="form-control item_link_sort" >
                    		
								<option value="">请选择</option>
                        		<option value="1" {{ d['link_sort'] == '1' ? 'selected="selected"' : '' }}>1</option>
                        		<option value="2" {{ d['link_sort'] == '2' ? 'selected="selected"' : '' }}>2</option>
                        		<option value="3" {{ d['link_sort'] == '3' ? 'selected="selected"' : '' }}>3</option>
							
                    		</select>
                		</div>
            		</div>
                    <div class="form-group">
                        <label for="service_unit" class="col-xs-2 control-label">点击处理所需数据</label>
                        <div class="col-xs-9">
                            <input type="text" class="form-control item_link_data" value="{{ d['link_data'] }}">
                            <p class="help-block pull-left">* 跳转某界面所需的数据，界面就填写相关的数据的ID，打开网页就是网址</p>
                        </div>
                    </div>
                </div>
            </div>
            {% endfor %}
            {% else %}
                <div class="panel panel-default banner_item">
                    <button class="btn btn-danger btn-sm banner_item_del" onclick="deleteItem(this)"><i class="fa fa-trash-o fa-lg"></i> 删除</button>
                    <div class="panel-body form-horizontal">
                        <div class="form-group">
                            <label for="service_cover" class="col-xs-2 control-label">图片</label>
                            <div class="col-xs-9">
                                <img src="" class="item_url" />
                                <button type="button" class="btn btn-warning btn-xs but_update_pic" onclick="uploadPic(this)"><i class="fa fa-pencil"></i>上传图片</button>
                                <p class="help-block">支持jpg、png图片格式，尺寸必须是750x330px，大小不得超过1M。</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="service_cover" class="col-xs-2 control-label">点击处理类型</label>
                            <div class="col-xs-3">
                                <select class="form-control item_link_type">
                                    <option value="">请选择...</option>
                                    <option value="none">点击无跳转</option>
                                    <option value="question">问题详情</option>
                                    <option value="activity">活动详情</option>
                                    <option value="url">内部打开网页</option>
                                    <option value="beautyParlor">美容院详情</option>
                                    <option value="beautyParlorService">美容院服务详情</option>
                                </select>
                            </div>
                        </div>
                       <div class="form-group">
                		<label  for="service_cover" class="col-xs-2 control-label">排序ID</label>
                		<div class="col-xs-3">
                    		<select class="form-control item_link_sort" >
                    		
								<option value="">请选择</option>
                        		<option value="1">1</option>
                        		<option value="2">2</option>
                        		<option value="3">3</option>
							
                    		</select>
                		</div>
            		</div>
                        <div class="form-group">
                            <label for="service_unit" class="col-xs-2 control-label">点击处理所需数据</label>
                            <div class="col-xs-9">
                                <input type="text" class="form-control item_link_data" value="">
                                <p class="help-block pull-left">* 到某界面就填写此界面的关联的数据的ID，打开网页就是网址</p>
                            </div>
                        </div>
                    </div>
                </div>
            {% endif %}
        </div>

        <div class="row">
        	{% if count(data) < 3 %}
            <div class="col-xs-12 text-right">
                <button class="btn btn-primary btn-sm" id="but_add_banner"><i class="fa fa-plus fa-lg"></i> 增 加</button>
            </div>
         	{% endif %}   
            <div class="col-xs-12 text-center">
                <button durl="{{ url.get('om/bannerIndex') }}" dcity="{{ filterCity }}" class="btn btn-primary" id="but_save"><i class="fa fa-floppy-o fa-lg"></i> 保 存</button>
            </div>
        </div>

        {% endif %}

    </div>

    <div id="item_tpl" class="hide">
        <div class="panel panel-default banner_item">
            <button class="btn btn-danger btn-sm banner_item_del" onclick="deleteItem(this)"><i class="fa fa-trash-o fa-lg"></i> 删除</button>
            <div class="panel-body form-horizontal">
                <div class="form-group">
                    <label for="service_cover" class="col-xs-2 control-label">图片</label>
                    <div class="col-xs-9">
                        <img src="" class="item_url" />
                        <button type="button" class="btn btn-warning btn-xs but_update_pic" onclick="uploadPic(this)"><i class="fa fa-pencil"></i>上传图片</button>
                        <p class="help-block">支持jpg、png图片格式，尺寸必须是750x330px，大小不得超过1M。</p>
                    </div>
                </div>
                <div class="form-group">
                    <label for="service_cover" class="col-xs-2 control-label">点击处理类型</label>
                    <div class="col-xs-3">
                        <select class="form-control item_link_type">
                            <option value="">请选择...</option>
                            <option value="none">点击无跳转</option>
                            <option value="question">问题详情</option>
                            <option value="activity">活动详情</option>
                            <option value="url">内部打开网页</option>
                            <option value="beautyParlor">美容院详情</option>
                            <option value="beautyParlorService">美容院服务详情</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                		<label  for="service_cover" class="col-xs-2 control-label">排序ID</label>
                		<div class="col-xs-3">
                    		<select class="form-control item_link_sort" >
                    		
								<option value="">请选择</option>
                        		<option value="1">1</option>
                        		<option value="2">2</option>
                        		<option value="3">3</option>
							
                    		</select>
                		</div>
            		</div>
                <div class="form-group">
                    <label for="service_unit" class="col-xs-2 control-label">点击处理所需数据</label>
                    <div class="col-xs-9">
                        <input type="text" class="form-control item_link_data" value="">
                        <p class="help-block pull-left">* 到某界面就填写此界面的关联的数据的ID，打开网页就是网址</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}